import { createApp } from 'vue'
// 引入echarts
import ECharts from 'vue-echarts'
// 引入nprogress进度条:在开始发送请求的时候开启进度条,在请求结束后关闭进度条
import nProgress from 'nprogress'
import 'nprogress/nprogress.css'
//引入ElementPlus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElIconModules from '@element-plus/icons'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
// 导入echarts
import 'echarts'
// 引入粒子效果插件
// import VueParticles from 'vue-particles'
//import Particles from 'particles.vue3'

// 导入路由规则
import router from './router'
// 全局引入VITE环境变量
import axios from 'axios'
axios.defaults.baseURL = import.meta.env.VITE_APP_URL // 后端地址是3001
// 通过axios拦截器控制进度条
axios.interceptors.request.use((config) => {
  // console.log('打印config:', config)
  config.headers.Authorization = window.sessionStorage.getItem('isLogin')
  nProgress.start() //进度条在顶上,一条蓝色的
  return config
})
axios.interceptors.response.use((config) => {
  nProgress.done()
  return config
})
//
const app = createApp(App)
// 统一注册el-icon图标
for (let iconName in ElIconModules) {
  app.component(iconName, ElIconModules[iconName])
}
// 挂载echarts组件
app.component('v-chart', ECharts)
app.use(ElementPlus)
// app.use(VueParticles)

app.use(router)
app.mount('#app')
